|
|
 |
|
|
|
|
If IsCulled Then Exit Sub
For pt = 1 To NumPts
If Points(pt).trans(3) >= R Then Exit For
Next pt
If pt <= NumPts Then IsCulled = True
End Sub
' Perform backface removal for the center
' of projection (X, Y, Z). Public Sub Cull(ByVal X As Single, ByVal Y As Single, _
ByVal Z As Single)
Dim Ax As Single
Dim Ay As Single
Dim Az As Single
Dim Nx As Single
Dim Ny As Single
Dim Nz As Single
' Compute a normal to the face. NormalVector Nx, Ny, Nz
' Compute a vector from the center of
' projection to the face. Ax = Points(1).coord(1) - X
Ay = Points(1).coord(2) - Y
Az = Points(1).coord(3) - Z
' See if the vectors meet at an angle < 90. IsCulled = (Ax * Nx + Ay * Ny + Az * Nz > -0.0001)
End Sub
' Compute a normal vector for this polygon. Public Sub NormalVector(ByRef Nx As Single, _
ByRef Ny As Single, ByRef Nz As Single)
Dim Ax As Single
Dim Ay As Single
Dim Az As Single
Dim Bx As Single
Dim By As Single
Dim Bz As Single
Ax = Points(2).coord(l) - Points(l).coord(l)
Ay = Points(2).coord(2) - Points(l).coord(2)
Az = Points(2).coord(3) - Points(l).coord(3)
Bx = Points(3).coord(1) - Points(2).coord(l)
By = Points(3).coord(2) - Points(2).coord(2)
Bz = Points(3).coord(3) - Points(2).coord(3)
m3Cross Nx, Ny, Nz, Ax, Ay, Az, Bx, By, Bz
End Sub |
|
|
|
|
|